package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.entity.DamageListGoods;
import com.atguigu.jxc.service.DamageListGoodsService;
import com.atguigu.jxc.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/damageListGoods")
public class DamageListGoodsController {

    @Autowired
    private DamageListGoodsService damageListGoodsService;


    @PostMapping("/save")
    public ServiceVO save(DamageList damageList, String damageListGoodsStr) {
        System.out.println(damageListGoodsStr);
        damageListGoodsService.save(damageList, damageListGoodsStr);
        return new ServiceVO(100, "添加成功");
    }

    @PostMapping("/list")
    public R list(String sTime, String eTime) {
        List<DamageList> damageList = damageListGoodsService.getList(sTime,eTime);
        return R.ok().put("rows",damageList);
    }

    @PostMapping("/goodsList")
    public R goodsList(Integer damageListId) {
        List<DamageListGoods> damageListGoods = damageListGoodsService.goodsList(damageListId);
        return R.ok().put("rows",damageListGoods);
    }
}
